/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.jisuanqi;

/**
 *
 * @author Lirz
 */
public class calculat {
    
    private double value;
    
    public void ac(){
        value = 0;
    }
     public void add(double number){
        value += number;
     }
     public void sub(double number){
        System.out.println("num:"+number +"value:"+value);
        if(value==0){
            value  = number;
        }else{
            value -= number;
        }
    }
     public void multiply(double number){
        value*=number;
     }
     public void divided(double number){
        try{
            value = value/number;
        }catch(Exception e){
            // TODO
        }
     }
     public double getvalue(){
           return value;
     }
      public static void main(String[] args){
        calculat calculator = new calculat();
        calculator.add(1);
        calculator.sub(1);
        calculator.multiply(2);
        calculator.divided(2);
        System.out.println(calculator.getvalue());
        calculator.ac();
        System.out.println(calculator.getvalue());
      }
}
